﻿using AllIsWell.Tests.TestData;
using NUnit.Framework;

namespace AllIsWell.Web.Tests.Controllers.HomeControllerTests
{
    [TestFixture]
    class Index : HomeControllerTest
    {
        private const int StartItWellId = 1;

        [Test]
        public void ShouldReturnIndexView()
        {
            var indexView = HomeController.Index();

            Assert.IsNotNull(indexView);
            Assert.AreEqual(string.Empty, indexView.ViewName);
        }

        [Test]
        public void ShouldPassTodaysPageForStartItWellIfItExists()
        {
            var expectedPage = PageSeed.GetPage();
            PageServiceMock.Setup(service => service.IsTodaysPageExists(StartItWellId)).Returns(true);
            PageServiceMock.Setup(service => service.GetTodaysPage(StartItWellId)).Returns(expectedPage);

            var indexView = HomeController.Index();

            Assert.AreEqual(expectedPage, indexView.Model);
        }

        [Test]
        public void ShouldPassNoModelIfTodaysPageNotExists()
        {
            PageServiceMock.Setup(service => service.IsTodaysPageExists(StartItWellId)).Returns(false);

            var indexView = HomeController.Index();

            Assert.IsNull(indexView.Model);
        }

    }
}